package com.hsc.yalebao.tabMine;

import android.annotation.SuppressLint;
import android.annotation.TargetApi;
import android.content.Context;
import android.content.res.Resources;
import android.os.Bundle;
import android.text.Editable;
import android.view.LayoutInflater;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemClickListener;
import android.widget.ArrayAdapter;
import android.widget.Button;
import android.widget.EditText;
import android.widget.ImageView;
import android.widget.ListView;
import android.widget.PopupWindow;
import android.widget.PopupWindow.OnDismissListener;
import android.widget.TextView;
import com.google.gson.Gson;
import com.hsc.yalebao.base.ActivityStack;
import com.hsc.yalebao.base.BaseActivity;
import com.hsc.yalebao.base.CustomApplication;
import com.hsc.yalebao.base.MainActivity;
import com.hsc.yalebao.http.AppConstants;
import com.hsc.yalebao.http.RequestNet;
import com.hsc.yalebao.model.BaseDataObject;
import com.hsc.yalebao.model.IsSetBankCardBean;
import com.hsc.yalebao.model.IsSetBankCardModel;
import com.hsc.yalebao.model.UserBaseBean;
import com.hsc.yalebao.tools.UiUtil;
import com.hsc.yalebao.weight.LogUtils;
import com.hsc.yalebao.weight.MyDialog1;
import com.zhy.http.okhttp.callback.StringCallback;
import java.util.HashMap;
import okhttp3.Call;

public class BoundBankCardActivity extends BaseActivity
{
  private String TAG = "-BoundBankCardActivity-";
  private String accountholder;
  private Context context;
  private EditText edit_user_card_address;
  private EditText edit_user_card_num;
  private EditText edit_user_card_type;
  public EditText edit_user_rela_name;
  private EditText edit_user_tixian_psw;
  private String guid = "";
  private ImageView img_commit;
  private ImageView img_user_card_type;
  public boolean isSetBankCard;
  private ImageView iv_title_right;
  private int memberid;
  private MyDialog1 myDialog1;
  View.OnClickListener onClickListener = new View.OnClickListener()
  {
    public void onClick(View paramAnonymousView)
    {
      switch (paramAnonymousView.getId())
      {
      case 2131099704:
      default:
        return;
      case 2131099699:
        BoundBankCardActivity.this.closeWindowSoftInput(BoundBankCardActivity.this.edit_user_tixian_psw);
        BoundBankCardActivity.this.closeWindowSoftInput(BoundBankCardActivity.this.edit_user_card_num);
        BoundBankCardActivity.this.closeWindowSoftInput(BoundBankCardActivity.this.edit_user_card_address);
        CustomApplication.app.finishActivity(BoundBankCardActivity.this);
        return;
      case 2131099735:
      case 2131099748:
        BoundBankCardActivity.this.showselectbangkPopwindow();
        return;
      case 2131099742:
      }
      BoundBankCardActivity.this.postBankCardInfo();
    }
  };
  public TextView tv_user_rela_name;
  View view;
  private View view_title;

  private void postBankCardInfo()
  {
    String str1 = this.edit_user_rela_name.getText().toString();
    String str2 = this.edit_user_card_type.getText().toString();
    String str3 = this.edit_user_card_num.getText().toString();
    String str4 = this.edit_user_card_address.getText().toString();
    String str5 = this.edit_user_tixian_psw.getText().toString();
    LogUtils.e(this.TAG, "guid:" + this.guid);
    if (!this.isSetBankCard)
    {
      if ("".equals(str1))
      {
        ShowDialog1("请输入您的真实姓名");
        return;
      }
      if (!UiUtil.isAllChinese(str1))
        ShowDialog1("请检查您的开户姓名");
    }
    else
    {
      this.isSetBankCard = true;
      str1 = this.accountholder;
    }
    if ("".equals(str2))
    {
      ShowDialog1("请选择您的银行卡类型");
      return;
    }
    if ("".equals(str3))
    {
      ShowDialog1("请输入您的卡号");
      return;
    }
    if (str3.length() < 16)
    {
      ShowDialog1("请检查您的卡号");
      return;
    }
    if (str3.length() > 19)
    {
      ShowDialog1("请检查您的卡号");
      return;
    }
    if ("".equals(str4))
    {
      ShowDialog1("输入您的银行卡开户地址");
      return;
    }
    if ("".equals(str5))
    {
      ShowDialog1("密码不能为空");
      return;
    }
    if (!UiUtil.isValidUserName(str5))
    {
      ShowDialog1("密码需要6~12位字符或数字");
      return;
    }
    HashMap localHashMap = new HashMap();
    localHashMap.put("bankname", str2);
    localHashMap.put("accountholder", str1);
    localHashMap.put("bankcardid", str3);
    localHashMap.put("guid", this.guid);
    localHashMap.put("bankaddress", str4);
    localHashMap.put("password", str5);
    setSureBtnIsEnable(false);
    RequestNet.get(this.context, AppConstants.URL_CHANGE_BANK_CARD, localHashMap, new StringCallback()
    {
      public void onError(Call paramAnonymousCall, Exception paramAnonymousException)
      {
        BoundBankCardActivity.this.setSureBtnIsEnable(true);
        LogUtils.e("返回失败", "result:" + paramAnonymousException);
      }

      public void onResponse(String paramAnonymousString)
      {
        BoundBankCardActivity.this.setSureBtnIsEnable(true);
        LogUtils.d("返回成功", "result:" + paramAnonymousString);
        Gson localGson = new Gson();
        try
        {
          localBaseDataObject = (BaseDataObject)localGson.fromJson(paramAnonymousString, BaseDataObject.class);
          if (localBaseDataObject == null)
          {
            BoundBankCardActivity.this.ShowDialog1("修改失败");
            UiUtil.showToast(BoundBankCardActivity.this.context, "绑定失败");
            return;
          }
        }
        catch (Exception localException)
        {
          BaseDataObject localBaseDataObject;
          do
          {
            while (true)
            {
              localException.printStackTrace();
              localBaseDataObject = null;
            }
            if (localBaseDataObject.getFlag() == 0)
            {
              BoundBankCardActivity.this.ShowDialog1(localBaseDataObject.getMsg());
              return;
            }
            if (localBaseDataObject.getFlag() == -2)
            {
              BoundBankCardActivity.this.showDownWireDialog();
              return;
            }
            if (localBaseDataObject.getFlag() == -3)
            {
              BoundBankCardActivity.this.ShowFengjinDialog();
              return;
            }
            if (localBaseDataObject.getFlag() == -4)
            {
              BoundBankCardActivity.activityStack.backToMain(MainActivity.class, BoundBankCardActivity.this.context);
              return;
            }
            if (localBaseDataObject.getFlag() == 3)
            {
              BoundBankCardActivity.this.ShowDialog1(localBaseDataObject.getMsg());
              return;
            }
          }
          while (localBaseDataObject.getFlag() != 1);
          BoundBankCardActivity.this.myDialog1.setMessage(localBaseDataObject.getMsg());
          BoundBankCardActivity.this.myDialog1.show();
          BoundBankCardActivity.this.myDialog1.btn_confirm.setOnClickListener(new View.OnClickListener()
          {
            public void onClick(View paramAnonymous2View)
            {
              CustomApplication.app.finishActivity(BoundBankCardActivity.this);
              BoundBankCardActivity.this.myDialog1.dismiss();
            }
          });
          BoundBankCardActivity.this.closeWindowSoftInput(BoundBankCardActivity.this.edit_user_tixian_psw);
          BoundBankCardActivity.this.edit_user_rela_name.setText("");
          BoundBankCardActivity.this.edit_user_card_type.setText("");
          BoundBankCardActivity.this.edit_user_card_num.setText("");
          BoundBankCardActivity.this.edit_user_card_address.setText("");
          BoundBankCardActivity.this.edit_user_tixian_psw.setText("");
        }
      }
    });
  }

  private void setSureBtnIsEnable(boolean paramBoolean)
  {
    if (paramBoolean)
      this.img_commit.setBackgroundResource(2130838215);
    while (true)
    {
      this.img_commit.setEnabled(paramBoolean);
      return;
      this.img_commit.setBackgroundResource(2130838087);
    }
  }

  @SuppressLint({"NewApi"})
  @TargetApi(12)
  private void showselectbangkPopwindow()
  {
    this.img_user_card_type.setImageResource(2130837882);
    this.view = LayoutInflater.from(this.context).inflate(2130903173, null);
    int i = this.edit_user_card_type.getWidth();
    final PopupWindow localPopupWindow = new PopupWindow(this.view, i, 500, true);
    ListView localListView = (ListView)this.view.findViewById(2131100233);
    final String[] arrayOfString = { "中国农业银行", "中国建设银行", "中国工商银行", "中国银行", "交通银行", "中国邮政储蓄银行", "招商银行", "兴业银行", "中信银行", "中国光大银行", "上海浦东发展银行", "中国民生银行", "深圳发展银行", "民生银行", "广东发展银行", "华夏银行" };
    localListView.setAdapter(new ArrayAdapter(this.context, 2130903047, arrayOfString));
    localListView.setOnItemClickListener(new AdapterView.OnItemClickListener()
    {
      public void onItemClick(AdapterView<?> paramAnonymousAdapterView, View paramAnonymousView, int paramAnonymousInt, long paramAnonymousLong)
      {
        try
        {
          BoundBankCardActivity.this.edit_user_card_type.setText(arrayOfString[paramAnonymousInt]);
          localPopupWindow.dismiss();
          return;
        }
        catch (Exception localException)
        {
          localException.printStackTrace();
        }
      }
    });
    localPopupWindow.setOutsideTouchable(true);
    localPopupWindow.setFocusable(true);
    localPopupWindow.setBackgroundDrawable(this.context.getResources().getDrawable(2130838170));
    localPopupWindow.showAsDropDown(this.edit_user_card_type, 0, 0);
    localPopupWindow.setOnDismissListener(new PopupWindow.OnDismissListener()
    {
      public void onDismiss()
      {
        BoundBankCardActivity.this.img_user_card_type.setImageResource(2130837881);
      }
    });
  }

  public void Issetbankcard()
  {
    if (CustomApplication.app.userBaseBean != null)
      this.memberid = CustomApplication.app.userBaseBean.getMemberid();
    HashMap localHashMap = new HashMap();
    localHashMap.put("memberid", this.memberid);
    LogUtils.d(this.TAG, "URL:" + AppConstants.URL_GET_ISSETBANKCARD);
    showLoadingDialog();
    RequestNet.get(this.context, AppConstants.URL_GET_ISSETBANKCARD, localHashMap, new StringCallback()
    {
      public void onError(Call paramAnonymousCall, Exception paramAnonymousException)
      {
        BoundBankCardActivity.this.dismissLoadingDialog();
        LogUtils.e(BoundBankCardActivity.this.TAG, "获取失败,获取提现记录:" + paramAnonymousException);
      }

      public void onResponse(String paramAnonymousString)
      {
        BoundBankCardActivity.this.dismissLoadingDialog();
        if (UiUtil.IsValueEmpty(paramAnonymousString))
          LogUtils.d(BoundBankCardActivity.this.TAG, "为空时result:" + paramAnonymousString);
        IsSetBankCardModel localIsSetBankCardModel;
        do
        {
          return;
          Gson localGson = new Gson();
          try
          {
            localIsSetBankCardModel = (IsSetBankCardModel)localGson.fromJson(paramAnonymousString, IsSetBankCardModel.class);
            if (localIsSetBankCardModel == null)
            {
              LogUtils.e(BoundBankCardActivity.this.TAG, "isSetBankCardModel，获取失败");
              return;
            }
          }
          catch (Exception localException)
          {
            while (true)
            {
              localException.printStackTrace();
              localIsSetBankCardModel = null;
            }
            if (localIsSetBankCardModel.getFlag() == 0)
            {
              BoundBankCardActivity.this.isSetBankCard = false;
              BoundBankCardActivity.this.edit_user_rela_name.setVisibility(0);
              BoundBankCardActivity.this.tv_user_rela_name.setVisibility(8);
              return;
            }
            if (localIsSetBankCardModel.getFlag() == -2)
            {
              BoundBankCardActivity.this.showDownWireDialog();
              return;
            }
            if (localIsSetBankCardModel.getFlag() == -3)
            {
              BoundBankCardActivity.this.ShowFengjinDialog();
              return;
            }
            if (localIsSetBankCardModel.getFlag() == -4)
            {
              BoundBankCardActivity.activityStack.backToMain(MainActivity.class, BoundBankCardActivity.this.context);
              return;
            }
          }
        }
        while (localIsSetBankCardModel.getFlag() != 1);
        IsSetBankCardBean localIsSetBankCardBean = localIsSetBankCardModel.getBankinfo();
        if (localIsSetBankCardBean == null)
        {
          LogUtils.e(BoundBankCardActivity.this.TAG, "isSetBankCardModel-result=null");
          return;
        }
        BoundBankCardActivity.this.isSetBankCard = true;
        BoundBankCardActivity.this.edit_user_rela_name.setVisibility(8);
        BoundBankCardActivity.this.tv_user_rela_name.setVisibility(0);
        BoundBankCardActivity.this.accountholder = localIsSetBankCardBean.getAccountholder();
        String str1 = localIsSetBankCardBean.getBankcardid();
        String str2 = localIsSetBankCardBean.getBankname();
        String str3 = localIsSetBankCardBean.getBankaddress();
        BoundBankCardActivity.this.tv_user_rela_name.setText(BoundBankCardActivity.this.accountholder);
        BoundBankCardActivity.this.edit_user_card_type.setText(str2);
        BoundBankCardActivity.this.edit_user_card_num.setText(str1);
        BoundBankCardActivity.this.edit_user_card_address.setText(str3);
      }
    });
  }

  protected void onCreate(Bundle paramBundle)
  {
    super.onCreate(paramBundle);
    setContentView(2130903045);
    CustomApplication.app.addActivity(this);
    this.context = this;
    setTitle(8, 0, 2130837809, "银行卡", 0, 8, 8, 0, true);
    this.edit_user_rela_name = ((EditText)findViewById(2131099747));
    this.edit_user_card_type = ((EditText)findViewById(2131099735));
    this.edit_user_card_type.setInputType(0);
    this.edit_user_card_type.setOnClickListener(this.onClickListener);
    this.img_user_card_type = ((ImageView)findViewById(2131099748));
    this.img_user_card_type.setOnClickListener(this.onClickListener);
    this.edit_user_card_num = ((EditText)findViewById(2131099737));
    this.edit_user_card_address = ((EditText)findViewById(2131099739));
    this.edit_user_tixian_psw = ((EditText)findViewById(2131099741));
    this.tv_user_rela_name = ((TextView)findViewById(2131099734));
    this.tv_user_rela_name.setText("获取中");
    this.img_commit = ((ImageView)findViewById(2131099742));
    this.img_commit.setOnClickListener(this.onClickListener);
    this.myDialog1 = new MyDialog1(this.context);
    if (CustomApplication.app.userBaseBean != null)
      this.guid = CustomApplication.app.userBaseBean.getGuid();
  }

  protected void onDestroy()
  {
    super.onDestroy();
  }

  protected void onPause()
  {
    super.onPause();
    closeWindowSoftInput(this.edit_user_tixian_psw);
    closeWindowSoftInput(this.edit_user_card_num);
    closeWindowSoftInput(this.edit_user_card_address);
  }

  protected void onResume()
  {
    super.onResume();
    Issetbankcard();
  }

  @SuppressLint({"NewApi"})
  public void setTitle(int paramInt1, int paramInt2, int paramInt3, String paramString, int paramInt4, int paramInt5, int paramInt6, int paramInt7, boolean paramBoolean)
  {
    View localView = findViewById(2131099716);
    if (paramBoolean)
      localView.setVisibility(0);
    while (true)
    {
      ((TextView)localView.findViewById(2131099701)).setText(paramString);
      ((TextView)localView.findViewById(2131099700)).setVisibility(paramInt1);
      ImageView localImageView = (ImageView)localView.findViewById(2131099699);
      localImageView.setVisibility(paramInt2);
      localImageView.setOnClickListener(this.onClickListener);
      localImageView.setImageResource(paramInt3);
      TextView localTextView = (TextView)localView.findViewById(2131099702);
      localTextView.setVisibility(paramInt5);
      localTextView.setOnClickListener(this.onClickListener);
      this.iv_title_right = ((ImageView)localView.findViewById(2131099704));
      this.iv_title_right.setVisibility(paramInt6);
      this.iv_title_right.setOnClickListener(this.onClickListener);
      this.iv_title_right.setImageResource(paramInt7);
      return;
      localView.setVisibility(8);
    }
  }
}

/* Location:           C:\Users\user\Desktop\dd28_pcdd720\classes_dex2jar.jar
 * Qualified Name:     com.hsc.yalebao.tabMine.BoundBankCardActivity
 * JD-Core Version:    0.6.2
 */